

import { _decorator, Component, Node, director, sys, view, ResolutionPolicy } from 'cc';
import { CardGroupParent } from './CardGroupParent';
const { ccclass, property } = _decorator;

@ccclass('GameAllData')
export default class GameAllData {
    private static _instance: GameAllData | null = null;

    public static get Instance() {
        return GameAllData._instance || (GameAllData._instance = new GameAllData());
    }

    constructor() {

    }

    ClearCurGameData()
    {
        this.isSequence=true;//正序出牌
        this.lastPlays=[];

        this.lastPlayUpScore=0;//上一个玩家上的分数
        //上一轮出牌组
        this.lastPlays=[];
    }

    ClearAllGameData()
    {
        this.isSequence=true;//正序出牌
        this.lastPlays=[];
        this.lastAllRanking=[];
        this.allRankingData=[];

        this.lastPlayUpScore=0;//上一个玩家上的分数
        //上一轮出牌组
        this.lastPlays=[];
    }

    //上一局排名数据
    //lastAllRanking=[-1,0,2,1,-2];
    lastAllRanking=[];

    allRankingData=[];


    SetLastPlay(cg:CardGroupParent)
    {
        this.lastPlays.push(cg);
    }

    isSequence=true;//正序出牌

    ScoreAccumulation()
    {
        let allScore=[0,0,0,0,0];
        for (let i = 0; i < this.allRankingData.length; i++) {
            for (let j = 0; j < 5; j++) {
                allScore[j]=allScore[j]+ this.allRankingData[i][j];
            }
        }
        return allScore;
    }


    //new
    lastPlayUpScore=0;//上一个玩家上的分数
    //上一轮出牌组
    lastPlays:CardGroupParent[]=[];
}
